package com.hkbigdata.transform;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;
import sun.java2d.pipe.ValidatePipe;

/**
 * @author liuanbo
 * @creat 2024-04-11-14:41
 * @see 2194550857@qq.com
 */
public class Flink02_TransForm_FlatMap_Anonymous {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        env.fromElements(1,2,3,4,5,6)
/*                .flatMap(new FlatMapFunction<Integer, Integer>() {
                    @Override
                    public void flatMap(Integer value, Collector<Integer> out) throws Exception {
                     out.collect(value*value);
                    }
                }).print();*/
                .flatMap((Integer data,Collector<Integer> out)->{
                    out.collect(data*data);
                }).returns(Types.INT).print();

        env.execute();
    }
}
